/**
 * 
 */
package co.fitstart.entity.order;

import com.demo2do.core.utils.Alias;

/**
 * 
 * @author mohanlan
 *
 */
@Alias("refundMethod")
public enum RefundMethod {

    /** 支付宝 */
    ALIPAY("alipay", "支付宝", "支付宝（口碑）", "3"),
    
    CONSTRUCTION_BANK("construction_bank", "建设银行", "建设银行", "202"),
    
    MERCHANTS_BANK("merchants_bank", "招商银行", "招商银行", "203"),
    
    CHINA_BANK("china_bank", "中国银行", "中国银行", "204");
    
    private String alias;
    
    private String description;
    
    private String name;
    
    private String code;
    
    RefundMethod(String alias, String description, String name, String code) {
        this.alias = alias;
        this.description = description;
        this.name = name;
        this.code = code;
    }
    
    /**
     * @return the alias
     */
    public String getAlias() {
        return alias;
    }
    
    /**
     * @return the description
     */
    public String getDescription() {
        return description;
    }
    
    /**
     * 
     * @return the name
     */
    public String getName() {
        return name;
    }
    
    /**
     * 
     * @return the code
     */
    public String getCode() {
        return code;
    }
    
    /**
     * Get payment method according to alias
     * 
     * @param alias
     * @return
     */
    public static RefundMethod aliasOf(String alias) {
        for (RefundMethod refundMethod : RefundMethod.values()) {
            if (refundMethod.getAlias().equalsIgnoreCase(alias)) {
                return refundMethod;
            }
        }
        return null;
    }
    
    /**
     * 
     * @param code
     * @return
     */
    public static RefundMethod codeOf(String code) {
        for (RefundMethod paymentMethod : RefundMethod.values()) {
            if (code != null && code.startsWith(paymentMethod.toString())) {
                return paymentMethod;
            }
        }
        return null;
    }
    
}
